/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package iQuizzView;

/**
 *
 * @author Etienne Parent-Jung Thomas Jouêtre
 */
public class PhoneController {
private PhoneNI ni;
private iQuizzGui gui;
private boolean started=false;
private int nbVotes;

    /**
     *
     * @param ni
     * @param gui
     */
    public PhoneController(PhoneNI ni,iQuizzGui gui) {
        this.ni = ni;
        this.gui=gui;
      
        
    }

    public boolean getStarted()
    {return started;}

     public void setStarted(boolean started)
    {this.started=started;}
    /**
     *
     */
    public void initialize(){
        ni.initialize();
    }

    /**
     *
     */
    public void sendConnect(int mdp){
        try {
            //on attend que le serveur soit trouvé
            // while(!ni.getReady())
            // {}
            Thread.sleep(8000);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        ni.connect(mdp);
    }

    /**
     *
     * @param vote
     */
    public void sendVote(int vote){
        ni.vote(vote);
    }

    /**
     *
     * @param nbVote
     */
    public void deblockVote(int nbVote){
        gui.switchDisplayable(null, gui.getList());
        this.nbVotes=nbVote;
    }

    public int getNbVote()
    {return nbVotes;}

public iQuizzGui getGui()
{
return gui;}
}
